<!-- doUserReg.php 用于将用户输入的注册信息添加到数据库。 -->

<?php

  

  require_once('./system/dbConnect.php');

  require_once('./system/MyFunc.php');

  //连接数据库		

  connect();



  if(!empty($_FILES["pic"]["name"])){

  	$pic = uploadfile('pic','images/',array('jpg','gif','png'));

  }

  else{

  	$pic='';

  }



  $data = array(

		'uname' => trim($_POST['username']),  

		'password' => $_POST['password'],

		'gender' => $_POST['gender'],

		'birthdate' => $_POST['birthdate'],

		'hobby' => implode($_POST['hobby'], ','),

		'degree' => $_POST['degree'],

		'intro' => $_POST['intro'],

		'pic'=>$pic

  	);



  //执行SQL语句

	$result = add('users',$data);



  if(!$result){

  	echo "注册失败！<br/>";

  	echo "<a href='userReg.html'>返回</a>";	  

  }else{	  

 	echo "注册成功！";

 	echo "请使用<a href='./login.html'>管理员登录</a>查看用户信息，";

	echo "或返回<a href='userReg.html'>注册</a>页面！";	  

  }    

  

?>



